package cn.gok;

import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

public class ArrayList的例子 {
    public static void main(String[] args) {
        遍历方法();
    }

    private static void 遍历方法() {
        List<String> list = Arrays.asList("aaa", "bbb", "ccc");

        for (int i = 0;i<list.size();i++){
            System.out.print(list.get(i)+" ");
        }
        for (String str:list){
            System.out.print(str+" ");
        }
        System.out.println();
        //迭代器
        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext()){
            String s = iterator.next();
            System.out.print(s+" ");
        }
        System.out.println();
    }
}
